package com.lagou.dao.impI;

import com.lagou.dao.IUserDao;

import java.util.*;

/**
 * @Author wsl
 * @Date 2021/11/7 20:15
 * @Project_Name jdbc_spring
 */
public class UserDaoImpI implements IUserDao {

    //1.1 注入普通数据类型
    private String username;
    private Integer age;

    //2.1 注入集合数据类型
    private List<Object> list;
    private Set<Object> set;
    private Object[] array;
    private Map<String,Object> map;
    private Properties properties;


    //2.2 用于set方法依赖注入
    public void setList(List<Object> list) {
        this.list = list;
    }

    public void setSet(Set<Object> set) {
        this.set = set;
    }

    public void setArray(Object[] array) {
        this.array = array;
    }

    public void setMap(Map<String, Object> map) {
        this.map = map;
    }

    public void setProperties(Properties properties) {
        this.properties = properties;
    }

    //1.2 用于set方法依赖注入
    public void setUsername(String username) {
        this.username = username;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    //测试生命周期
    public void init(){
        System.out.println("初始化方法执行了......");
    }

    public void destroy(){
        System.out.println("销毁方法执行了......");
    }

    //方法
    public void save() {

        //1.3 注入普通数据类型
        System.out.println(username);//打篮球
        System.out.println(age);//18

        System.out.println("----------------------------------------------------");

        //2.3 注入集合数据类型
        System.out.println("list集合："+ list);//[aaa, User{username='戴羽彤', age=18}]
        System.out.println("set集合："+ set);//[bbb, User{username='戴羽彤', age=18}]
        System.out.println("array数组："+ Arrays.toString(array));//[ccc, User{username='戴羽彤', age=18}]
        System.out.println("map集合：" +map);//{k1=ddd, k2=User{username='戴羽彤', age=18}}
        System.out.println("properties："+ properties);//{k1=v1, k2=v2, k3=v3}

        System.out.println("dao层被调用了......");
    }

}
